# llms/db_config.py 配置文件

import os
from pathlib import Path
from dotenv import load_dotenv

# 加载.env文件
load_dotenv()


# 创建一个配置类
class Config:
    def __init__(self):
        pass

    BASE_DIR = Path(__file__).resolve().parent.parent
    LOG_PATH = os.path.join(BASE_DIR, 'logs')
    LOG_NAME = 'app.log'
    LOG_FILE = os.path.join(LOG_PATH, LOG_NAME)

    # DEBUG
    DEBUG = True

    # DB数据库配置
    DB_HOST = os.getenv('DB_HOST')
    DB_PORT = os.getenv('DB_PORT')
    DB_USER = os.getenv('DB_USER')
    DB_PASSPORT = os.getenv('DB_PASSWORD')
    DB = os.getenv('DB_NAME')
    SQLALCHEMY_DATABASE_URI = f'mysql+pymysql://{DB_USER}:{DB_PASSPORT}@{DB_HOST}:{DB_PORT}/{DB}?charset=utf8mb4'
    SQLALCHEMY_TRACK_MODIFICATIONS = True
    SQLALCHEMY_ENCODING = 'utf-8'
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    # 配置Redis数据库
    REDIS_HOST = os.getenv('REDIS_HOST')
    REDIS_PORT = os.getenv('REDIS_PORT')
    REDIS_PASSWORD = os.getenv('REDIS_PASSWORD')
    REDIS_DB = os.getenv('REDIS_DB')

    # 配置邮件服务
    MAIL_SERVER = os.getenv('MAIL_SERVER')
    MAIL_PORT = os.getenv('MAIL_PORT')
    MAIL_USE_SSL = True



